#define DEBUG
#include <cstdio>
#define MAXN 1000
#define MAXM 1000

using namespace std;

int main() {
#ifdef DEBUG
  freopen("3053.in", "r", stdin);
  freopen("3053.out", "w", stdout);
#endif

  static char map[MAXN+1][MAXM+1];
  static int posr[MAXN+1], posc[MAXM+1];
  static long long sumr[MAXN+1], sumc[MAXM+1], f[MAXN+1][MAXM+1];
  int n, m;
  long long sum=0;
  scanf("%d %d ", &n, &m);
  for (int i=1; i<=n; i++) {
    for (int j=1; j<=m; j++) {
      scanf("%c", &map[i][j]);
      if (map[i][j]=='.') {
	sumr[i]++, sumc[j]++;
	f[0][0] += i+j;
	sum++;
      } else {
	posr[i] = j, posc[j] = i;
      }
    }
    scanf(" ");
  }
  for (int i=1; i<=n; i++) {
    sumr[i] += sumr[i-1];
  }
  for (int i=1; i<=m; i++) {
    sumc[i] += sumc[i-1];
  }

  long long ans=0;
  for (int i=1; i<=n; i++) {
    f[i][0] = f[i-1][0]+sumr[i-1]-(sum-sumr[i-1]);
    for (int j=1; j<=m; j++) {
      f[i][j] = f[i][j-1]+sumc[j-1]-(sum-sumc[j-1]);
      if (map[i][j]=='.') {
	ans += f[i][j];
      }
    }
  }
  
  for (int i=1; i<=n; i++) {
    if (posr[i]) {
      ans += (posr[i]-1)*(m-posr[i])*4L;
      if (i<n) {
	bool flag=posr[i]<posr[i+1];
	for (int j=i+1; j<=n && posr[j] && (flag ? posr[j-1]<posr[j] : posr[j-1]>posr[j]); j++) {
	  ans += flag ? (posr[i]-1)*(m-posr[j])*4L : (posr[j]-1)*(m-posr[i])*4L;
	}
      }
    }
  }
  for (int i=1; i<=m; i++) {
    if (posc[i]) {
      ans += (posc[i]-1)*(n-posc[i])*4L;
      if (i<m) {
	bool flag=posc[i]<posc[i+1];
	for (int j=i+1; j<=m && posc[j] && (flag ? posc[j-1]<posc[j] : posc[j-1]>posc[j]); j++) {
	  ans += flag ? (posc[i]-1)*(n-posc[j])*4L : (posc[j]-1)*(n-posc[i])*4L;
	}
      }
    }
  }

  printf("%.4LF", (long double)ans/(sum*sum));

  fclose(stdin);
  fclose(stdout);
  return 0;
}
